﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace LuxuryReport.DataService.Mapping
{
    // Use a data contract as illustrated in the sample below to add composite types to service operations
    [DataContract]
    public class Room
    {
        [DataMember]
        public Guid RMID
        {
            get;
            set;
        }

        [DataMember]
        public string RoomNo
        {
            get;
            set;
        }

        [DataMember]
        public string RoomType
        {
            get;
            set;
        }

        [DataMember]
        public bool IsAvailable
        {
            get;
            set;
        }

        [DataMember]
        public decimal PriceUnit
        {
            get;
            set;
        }
        

        public static Room MapToRoom(LuxuryResort.Entity.Room efRoom)
        {
            if (efRoom == null) return null;

            var room = new Room()
            {
                RMID = efRoom.RMID,
                RoomNo = efRoom.RoomNo.Value.ToString(),
                RoomType = efRoom.RoomType,
                IsAvailable = efRoom.IsAvailable == null ? false: efRoom.IsAvailable.Value,
                PriceUnit = efRoom.PriceUnit == null ? 0m: efRoom.PriceUnit.Value
            };

            return room;
        }

         public static LuxuryResort.Entity.Room MapToEFRoom(Room serviceRoom)
        {
            if (serviceRoom == null) return null;

            var room = new LuxuryResort.Entity.Room()
            {
                RMID = serviceRoom.RMID,
                RoomNo = Convert.ToInt32(serviceRoom.RoomNo),
                RoomType = serviceRoom.RoomType,
                IsAvailable = serviceRoom.IsAvailable,
                PriceUnit = serviceRoom.PriceUnit
            };

            return room;
        }
    }

    [DataContract]
    public class Reservation
    {
        [DataMember]
        public Guid RMID
        {
            get;
            set;
        }

        [DataMember]
        public string CustomerName
        {
            get;
            set;
        }

        [DataMember]
        public int Quantity
        {
            get;
            set;
        }

        [DataMember]
        public string PaymentMethod
        {
            get;
            set;
        }

       [DataMember]
        public Guid CreatedBy
        {
            get;
            set;
        }

        [DataMember]
        public DateTime CreatedAt
        {
            get;
            set;
        }

        [DataMember]
        public DateTime CheckIn
        {
            get;
            set;
        }

        [DataMember]
        public DateTime CheckOut
        {
            get;
            set;
        }

        [DataMember]
        public Boolean PaymentDone
        {
            get;
            set;
        }


        public static LuxuryResort.Entity.Reservation MapToReservation(Reservation reservation)
        {
            if (reservation == null) return null;

            var r = new LuxuryResort.Entity.Reservation()
            {
                RMID = reservation.RMID,
                Quantity = reservation.Quantity,
                PaymentMethod = reservation.PaymentMethod,
                CustomerName = reservation.CustomerName,
                CreatedBy = reservation.CreatedBy,
                CreatedAt = reservation.CreatedAt,
                RSID = Guid.NewGuid(),
                CheckIn = reservation.CheckIn,
                CheckOut = reservation.CheckOut,
                PaymentDone=  reservation.PaymentDone
                
            };

            return r;
        }
    }

    [DataContract]
    public class FoodOrder
    {
        [DataMember]
        public Guid ID
        {
            get;
            set;
        }

        [DataMember]
        public Guid FID
        {
            get;
            set;
        }

        [DataMember]
        public string CustomerName
        {
            get;
            set;
        }

        [DataMember]
        public Guid CreatedBy
        {
            get;
            set;
        }

        [DataMember]
        public DateTime CreatedAt
        {
            get;
            set;
        }

        [DataMember]
        public Boolean PaymentDone
        {
            get;
            set;
        }

        [DataMember]
        public decimal Total
        {
            get;
            set;
        }

        public static LuxuryResort.Entity.Food_Beverage_Order MapToFoodOrder(FoodOrder fo)
        {
            if (fo == null) return null;

            var item = new LuxuryResort.Entity.Food_Beverage_Order()
            {
               ID = fo.ID,
               FID = fo.FID,
               CustomerName = fo.CustomerName,
               OrderedBy = fo.CreatedBy,
               OrderedAt = fo.CreatedAt,
               Total = fo.Total
            };

            return item;
        }
    }
}
